package org.chispa.api.util;

import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;

public enum RelationalSymbol {
	
	EQUALS("=="),LESS("<"),LESS_OR_EQ("<="),GREATER(">"),GRT_OR_EQ(">="),NOT_EQUAL("!=");
	
	private String symbol;

	private RelationalSymbol(String symbol){this.symbol=symbol;};
	
	private static Map<String,RelationalSymbol> repo= new HashMap<String,RelationalSymbol>();

	static {
          for(RelationalSymbol rel : EnumSet.allOf(RelationalSymbol.class))
        	  repo.put(rel.symbol,rel);
	}
	
	public static RelationalSymbol fromString(String symbol)
	{
		return repo.get(symbol);
	}
	
	public RelationalSymbol doSwitch()
	{
		switch(this) {
		case LESS:
			return GREATER;
		case GREATER:
			return LESS;
		case GRT_OR_EQ:
			return LESS_OR_EQ;
		case LESS_OR_EQ:
			return GRT_OR_EQ;
		default:
			return this;
		}
	}

}
